package com.jeomo.mem.starter.mapper;

import com.jeomo.base.starter.mapper.IBaseMapper;
import com.jeomo.mem.starter.entity.MemberPointsSupplement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

/**
 * 会员积分补录
 *
 * @author:Jackpot
 * @create 2020-10-13 20:29
 * @description:
 */
@Mapper
public interface MemberPointsSuppleMapper extends IBaseMapper<MemberPointsSupplement> {


    @Update("update member_points_supplement set workflow_status=#{status},auditor=#{auditor}," +
            "audit_time=#{auditTime} where code=#{code}")
    int updateWorkflowStatus(String code, LocalDateTime auditTime, String auditor, int status);

    @Select("select COUNT(*) from member_points_supplement WHERE org=#{orgCode} and workflow_status='1' ")
    int queryToDoPhotographIntegral(String orgCode);

    /**
     * 查询重复数据
     * @param orderNo   订单号
     * @param merchant  商户
     * @param payAmount 消费金额
     * @return
     */
    @Select("select COUNT(*) from member_points_supplement as m " +
            "WHERE m.order_no=#{orderNo} and m.merchant=#{merchant} and m.pay_amount=#{payAmount}")
    int queryRepeat(@Param("orderNo") String orderNo,@Param("merchant") String merchant,@Param("payAmount") Double payAmount);
}
